<template>
  <div>
    <el-dialog
      :visible.sync="dialogVisible"
      width="800px"
      :before-close="handleClose"
    >
    <template slot="title">
      <div>{{ form.type | typeFilter }}审核</div>
    </template>
      <el-form :model="form" inline label-width="120px">
        <el-form-item >
          <template slot="label">
            <span>回复内容:</span>
          </template>
          <div style="width: 600px">{{ form.comment }}</div>
        </el-form-item>
        <el-form-item>
          <template slot="label">
            <span>{{ form.type | typeFilter }}:</span>
          </template>
          <div style="width: 600px">{{ form.title }}</div>
        </el-form-item>
        <el-form-item label="是否置顶:">
          <el-radio-group style="width: 600px" v-model="form.topStatus">
            <el-radio :label="0">否</el-radio>
            <el-radio :label="1">是</el-radio>
          </el-radio-group>
        </el-form-item>
        <el-form-item label="审核状态:">
          <el-radio-group style="width: 600px" v-model="form.verifyStatus">
            <el-radio :label="1">通过</el-radio>
            <el-radio :label="2">不通过</el-radio>
          </el-radio-group>
        </el-form-item>
      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button style="width: 80px" size="small" @click="handleClose()"
          >取消</el-button
        >
        <el-button
          style="width: 80px"
          size="small"
          type="primary"
          @click="onSubmit()"
          >提交</el-button
        >
      </span>
    </el-dialog>
  </div>
</template>
<script>
import { editCommentAudit } from "@/api/article";
export default {
  name: "edit",
  filters: {
    typeFilter(type) {
      const mapObj = {
        1: "文章",
        4: "问答",
        3: "短视频"
      };
      return mapObj[type];
    }
  },
  data() {
    return {
      dialogVisible: false,
      form: {}
    };
  },
  methods: {
    opendialog(v) {
      console.log("v", v)
      this.form = {
        ...v,
        topStatus: 0,
        verifyStatus: 1
      };
      this.dialogVisible = true;
    },
    handleClose() {
      this.dialogVisible = false;
    },
    onSubmit() {
      let params = {
        topStatus: this.form.topStatus,
        verifyStatus: this.form.verifyStatus,
        replayId: this.form.replayId,
        commentId: this.form.commentId
      };

      console.log(params);
      editCommentAudit(params).then(res => {
        this.$message.success("审核成功");
        this.$emit("getList");
        this.handleClose();
      });
    }
  }
};
</script>

<style scoped lang="scss"></style>
